#include "audio.h"

////// The CAudio implementation

CAudio::CAudio() {
	sound = NULL;
	channel = -1;
}

CAudio::~CAudio() {
	if (sound)
		Mix_FreeChunk(sound);
	sound = NULL;
}

void CAudio::SetSound(Mix_Chunk * s) {
	if (sound)
		Mix_FreeChunk(sound);
	sound = s;
}

void CAudio::SetVolume(float volume)
{
	int v = int(volume);

	if (sound)
		Mix_VolumeChunk(sound, v);

	if (channel != -1)
		Mix_Volume(channel, v);
}

